#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;
using tl = tuple < int, int, int >;

const int mod = 19940417;
const int inv2 = (mod + 1) >> 1;
const int inv3 = (mod + 1) / 3;

int n, m, ans;

inline ll s1(int x) { return 1ll * x * (x + 1) / 2 % mod; }
inline ll s2(int x) { return 1ll * x * (x + 1) % mod * (x * 2 + 1) % mod * inv2 % mod * inv3 % mod; }
inline ll s1(int x, int y) { return (s1(y) - s1(x - 1) + mod) % mod; }
inline ll s2(int x, int y) { return (s2(y) - s2(x - 1) + mod) % mod; }

ll G(int x, int lim) {
	ll ans = 0;
	for(int l = 1, r; l <= lim; l = r + 1) {
		r = min(x / (x / l), lim);
		ans += s1(l, r) * (x / l) % mod;
		ans %= mod;
	}
	return ans;
}

ll F(int x) { return (1ll * x * x % mod - G(x, x) + mod) % mod; }
ll T(int x, int y) {
	ll ans = 0;
	for(int l = 1, r; l <= x && l <= y; l = r + 1) {
		r = min(x / (x / l), y / (y / l));
		ans += s2(l, r) * (x / l) % mod * (y / l) % mod;
		ans %= mod;
	} return ans;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in, m = in;
	ans = 1ll * F(n) * F(m) % mod;
	(ans += mod - 1ll * n * m % mod * min(n, m) % mod) %= mod;
	(ans += 1ll * G(n, min(n, m)) * m % mod) %= mod;
	(ans += 1ll * G(m, min(n, m)) * n % mod) %= mod;
	(ans += mod - T(n, m)) %= mod;
	printf("%d\n", ans);
	return 0;
}
